// IKafkaConsumer.cs
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace Beauty.Net.Kafka
{
    /// <summary>
    /// Kafka 消费者接口
    /// </summary>
    public interface IKafkaConsumer : IDisposable
    {
        /// <summary>
        /// 订阅主题
        /// </summary>
        /// <param name="topics">主题列表</param>
        void Subscribe(IEnumerable<string> topics);

        /// <summary>
        /// 取消订阅
        /// </summary>
        void Unsubscribe();

        /// <summary>
        /// 开始消费
        /// </summary>
        /// <param name="cancellationToken">取消令牌</param>
        /// <param name="messageHandler">消息处理函数</param>
        Task StartConsumeAsync(CancellationToken cancellationToken, Func<IKafkaMessage, Task> messageHandler);

        /// <summary>
        /// 手动提交偏移量
        /// </summary>
        void Commit();

        /// <summary>
        /// 异步提交偏移量
        /// </summary>
        Task CommitAsync();
    }
}

